<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-20
 * @package TinPhp
 */
if (!defined('IN_TINPHP')) {
	exit ('Access Denied');
}
/**
 * DB type definitions
 * Only includes common DB types
 */
class DB {
  const BOOL                = 0; // 'true' or 'false'

  const INT                 = 100;  // -2147483648 to 2147483647
  const UNSIGNED_INT        = 101; // 0 to 4294967295
  const TINYINT             = 102; // -128 to 127
  const UNSIGNED_TINYINT    = 103; // 0 to 255
  const SMALLINT            = 104; // -32768 to 32767
  const UNSIGNED_SMALLINT   = 105; // 0 to 65535
  const MEDIUMINT           = 106; // -8388608 to 8388607
  const UNSIGNED_MEDIUMINT  = 107; // 0 to 16777215
  const BIGINT              = 108; // -9223372036854775808 to 9223372036854775807
  const UNSIGNED_BIGINT     = 109; // 0 to 18446744073709551615

  const FLOAT               = 200;
  const UNSIGNED_FLOAT      = 201;
  const DOUBLE              = 202;
  const UNSIGNED_DOUBLE     = 203;
  const DECIMAL             = 204;
  const UNSIGNED_DECIMAL    = 205;

  const CHAR                = 300;
  const VARCHAR             = 301;
  const ENUM                = 302;
  const TEXT                = 303;
  const BLOB                = 304;
  const CLOB                = 305;

  const DATE                = 400; // '2008-11-01'
  const DATETIME            = 401; // '2008-11-01 22:12:23'
  const TIMESTAMP           = 402; // '2008-11-01 22:12:23'
  const TIME                = 403; // '2008-11-01'
  const YEAR                = 404; // 2008


  public static function DB_TABLE($tableAlias, $isPrefix = true, $dbtype='mysql') {
  	$tin_table_prefix = $GLOBALS['TIN_DB_CONN'][$dbtype];
  	if ($isPrefix == true && $tin_table_prefix['tabprefix']!=""){
      return $tin_table_prefix['tabprefix'] . $tableAlias;
      //return strtoupper($tin_table_prefix['tabprefix'] . $tableAlias);	//区分大小写的注意
    }else{
      return $tableAlias;
      //return strtoupper($tableAlias);	//区分大小写的注意
    }
  }

  public static function isStrType($type) {
    switch ($type) {
    case DB::CHAR:
    case DB::VARCHAR:
    case DB::TEXT:
    case DB::ENUM:
      return true;
    default:
      return false;
    }
  }
}

?>
